﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="设备登记.aspx.cs" Inherits="syc.Jidong.设备登记" %>
<html>
<head>
<title></title>
</head>
<style>
#BianHao{background-image:url(/images/bmback.gif); background-repeat:no-repeat;}
</style>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"

SelectCommand="Select @编码=编码,@名称=名称,@投产日期=投产日期,@型号=isnull(型号,''),@厂家=isnull(厂家,'')
,@出厂编号=isnull(出厂编号,''),@出厂日期=出厂日期,@大小=isnull(大小,''),@功率=功率,@安装地点=isnull(安装地点,'')
,@折旧年限=折旧年限,@购置费=购置费,@附加费=附加费,@验收意见=isnull(验收意见,''),@验收人=isnull(验收人,''),@备注=isnull(备注,''),@单位编码=单位编码,@资产编码=资产编码,@序号=序号 from 设备台账 where ID=@BillID;"

InsertCommand="if not exists (select ID from 设备台账 where 编码=@编码)
begin
Insert into 设备台账(编码,名称,投产日期,型号,厂家,出厂编号,出厂日期,大小,功率,安装地点,折旧年限,购置费,附加费,验收意见,验收人,备注,单位编码,资产编码,序号)values(
@编码,@名称,@投产日期,@型号,@厂家,@出厂编号,@出厂日期,@大小,@功率,@安装地点,@折旧年限,@购置费,@附加费,@验收意见,@验收人,@备注,@单位编码,@资产编码,@序号);
set @BillID=@@IDENTITY;
end
else
begin
set @BillID=0;
end"
UpdateCommand="if not exists (select ID from 设备台账 where 编码=@编码 and ID!=@BillID)
begin
update 设备台账 set 编码=@编码,名称=@名称,投产日期=@投产日期,型号=@型号,厂家=@厂家
,出厂编号=@出厂编号,出厂日期=@出厂日期,大小=@大小,功率=@功率,安装地点=@安装地点
,折旧年限=@折旧年限,购置费=@购置费,附加费=@附加费,验收意见=@验收意见,验收人=@验收人,备注=@备注,资产编码=@资产编码,序号=@序号
where ID=@BillID;
end"
oninserted="SqlDataSource1_Inserted" onselected="SqlDataSource1_Selected"
>
<SelectParameters>
<asp:Parameter Name="BillID" Size="4" DbType="Int32"/>
<asp:Parameter Name="编码" DbType="AnsiStringFixedLength"  Size="18" Direction="Output"/>
<asp:Parameter Name="名称" DbType="String"  Size="40" Direction="Output"/>
<asp:Parameter Name="投产日期" DbType="Date"  Size="3" Direction="Output"/>
<asp:Parameter Name="型号" DbType="AnsiString" Size="20" Direction="Output"/>
<asp:Parameter Name="厂家" DbType="String"  Size="40" Direction="Output"/>
<asp:Parameter Name="出厂编号" DbType="String"  Size="20" Direction="Output"/>
<asp:Parameter Name="出厂日期" DbType="String"  Size="20" Direction="Output"/>
<asp:Parameter Name="大小" DbType="AnsiString"   Size="20" Direction="Output"/>
<asp:Parameter Name="功率" DbType="Double"  Size="8" Direction="Output"/>
<asp:Parameter Name="安装地点" DbType="String"  Size="40" Direction="Output"/>
<asp:Parameter Name="折旧年限" DbType="Int16"  Size="2" Direction="Output"/>
<asp:Parameter Name="购置费" DbType="Currency"  Size="9" Direction="Output"/>
<asp:Parameter Name="附加费" DbType="Currency"  Size="9" Direction="Output"/>
<asp:Parameter Name="验收意见" DbType="String"  Size="100" Direction="Output"/>
<asp:Parameter Name="验收人" DbType="String"  Size="20" Direction="Output"/>
<asp:Parameter Name="备注" DbType="String"  Size="100" Direction="Output"/>
<asp:Parameter Name="单位编码" Size="4" DbType="Int32" Direction="Output"/>
<asp:Parameter Name="资产编码" Size="4" DbType="Int32" Direction="Output"/>
<asp:Parameter Name="序号" Size="2" DbType="Int16" Direction="Output"/>

</SelectParameters>
<InsertParameters>
<asp:Parameter Name="BillID" Direction="Output" Size="4" DbType="Int32"/>
<asp:Parameter Name="编码" DbType="AnsiStringFixedLength"  Size="18"/>
<asp:Parameter Name="名称" DbType="String"  Size="40"/>
<asp:Parameter Name="投产日期" DbType="Date"  Size="3"/>
<asp:Parameter Name="型号" DbType="AnsiString" Size="20"/>
<asp:Parameter Name="厂家" DbType="String"  Size="40"/>
<asp:Parameter Name="出厂编号" DbType="String"  Size="20"/>
<asp:Parameter Name="出厂日期" DbType="String"  Size="20"/>
<asp:Parameter Name="大小" DbType="AnsiString"   Size="20"/>
<asp:Parameter Name="功率" DbType="Double"  Size="8"/>
<asp:Parameter Name="安装地点" DbType="String"  Size="40"/>
<asp:Parameter Name="折旧年限" DbType="Int16"  Size="2"/>
<asp:Parameter Name="购置费" DbType="Decimal"  Size="9"/>
<asp:Parameter Name="附加费" DbType="Decimal"  Size="9"/>
<asp:Parameter Name="验收意见" DbType="String"  Size="100"/>
<asp:Parameter Name="验收人" DbType="String"  Size="20"/>
<asp:Parameter Name="备注" DbType="String"  Size="100"/>
<asp:Parameter Name="单位编码" Size="4" DbType="Int32"/>
<asp:Parameter Name="资产编码" Size="4" DbType="Int32"/>
<asp:Parameter Name="序号" Size="2" DbType="Int16"/>
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="BillID" Size="4" DbType="Int32"/>
<asp:Parameter Name="编码" DbType="AnsiStringFixedLength"  Size="18"/>
<asp:Parameter Name="名称" DbType="String"  Size="40"/>
<asp:Parameter Name="投产日期" DbType="Date"  Size="3"/>
<asp:Parameter Name="型号" DbType="AnsiString" Size="20"/>
<asp:Parameter Name="厂家" DbType="String"  Size="40"/>
<asp:Parameter Name="出厂编号" DbType="String"  Size="20"/>
<asp:Parameter Name="出厂日期" DbType="String"  Size="20"/>
<asp:Parameter Name="大小" DbType="AnsiString"   Size="20"/>
<asp:Parameter Name="功率" DbType="Double"  Size="8"/>
<asp:Parameter Name="安装地点" DbType="String"  Size="40"/>
<asp:Parameter Name="折旧年限" DbType="Int16"  Size="2"/>
<asp:Parameter Name="购置费" DbType="Decimal"  Size="9"/>
<asp:Parameter Name="附加费" DbType="Decimal"  Size="9"/>
<asp:Parameter Name="验收意见" DbType="String"  Size="100"/>
<asp:Parameter Name="验收人" DbType="String"  Size="20"/>
<asp:Parameter Name="备注" DbType="String"  Size="100"/>
<asp:Parameter Name="资产编码" Size="4" DbType="Int32"/>
<asp:Parameter Name="序号" Size="2" DbType="Int16"/>
</UpdateParameters>

</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
SelectCommand="select ID, cast(id as char(7))+名称 as 名称 FROM 单位编码 where id between 350000 and 359999">
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource3" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"

    SelectCommand="select @折旧年限=折旧年限 from 资产编码 where id=@ID" 
    onselected="SqlDataSource3_Selected">
<SelectParameters>
<asp:Parameter Name="ID" Size="4" DbType="Int32"/>
<asp:Parameter Name="折旧年限" Size="1" DbType="Byte" Direction="Output"/>
</SelectParameters>
</asp:SqlDataSource>

<asp:Label ID="BillID" runat="server" Text="" Visible="false"></asp:Label>
<div id="wintop" class="wintop">设备资产登记</div>

<asp:Panel ID="Panel1" runat="server" CssClass="panel">
    <asp:Button ID="Button_Save" runat="server" Text="保 存" UseSubmitBehavior="false" 
        CssClass="button" onclick="Button_Save_Click" />
    <input type="button" value="关 闭" class="button" onclick="parent.swin2_close();" />
</asp:Panel>

<asp:Panel ID="Panel2" runat="server" CssClass="panel">
<table border="1" style="border-collapse:separate;font-size:14px;">
	<tr height="36">
		<td width=90 align="right">使用单位:</td>
		<td width=160>
            <asp:DropDownList ID="BuMeng" runat="server" DataSourceID="SqlDataSource2" 
                DataTextField="名称" DataValueField="ID" Width="150px" Font-Size="13px" 
                onselectedindexchanged="BuMeng_SelectedIndexChanged" AutoPostBack="True"></asp:DropDownList></td>
		<td width=120 align="right">资产类别编码:</td>
		<td width=160><asp:TextBox ID="ZiChan" runat="server" CssClass="textbox" 
                Width="120" AutoPostBack="True" ontextchanged="ZiChan_TextChanged"></asp:TextBox></td>
		<td width=90 align="right">序号:</td>
		<td width=160><asp:TextBox ID="XuHao" runat="server" CssClass="textbox" Width="120" 
                AutoPostBack="True" ontextchanged="XuHao_TextChanged"></asp:TextBox></td>
	</tr>

	<tr height="36">
		<td align="right">资产编号:</td>
		<td><asp:TextBox ID="BianHao" runat="server" CssClass="textbox" Width="130" 
                Enabled="false" Font-Size="12px" AutoPostBack="True" ></asp:TextBox></td>
		<td align="right">资产名称:</td>
		<td><asp:TextBox ID="MingCheng" runat="server" CssClass="textbox" Width="100%"></asp:TextBox></td>
		<td align="right">投产日期:</td>
		<td><asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="120"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" /></td>
	</tr>
	<tr height="36">
		<td align="right">规格型号:</td>
		<td><asp:TextBox ID="XingHao" runat="server" CssClass="textbox" Width="100%"></asp:TextBox></td>
		<td align="right">生成厂家:</td>
		<td><asp:TextBox ID="ChangJia" runat="server" CssClass="textbox" Width="100%"></asp:TextBox></td>
		<td align="right">出厂日期:</td>
		<td><asp:TextBox ID="Date2" runat="server" CssClass="textbox" Width="120"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" /></td>
	</tr>
	<tr height="36">
		<td align="right">出厂编号:</td>
		<td><asp:TextBox ID="ChuChangBH" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
		<td align="right">面积或重量:</td>
		<td><asp:TextBox ID="DaXiao" runat="server" CssClass="textbox" Width="100"></asp:TextBox>㎡ 或 T</td>
		<td align="right">功率(KW):</td>
		<td><asp:TextBox ID="GongLv" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
	</tr>
	<tr height="36">
		<td align="right">安装地点:</td>
		<td><asp:TextBox ID="DiDian" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
		<td align="right">折旧年限:</td>
		<td><asp:TextBox ID="NianXian" runat="server" CssClass="textbox" Width="100" 
                BackColor="#eeeeee" Enabled="False"></asp:TextBox>年</td>
		<td align="right"></td>
		<td></td>
	</tr>
	<tr height="36">
		<td align="right">购置费(元):</td>
		<td><asp:TextBox ID="GouZhiFei" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
		<td align="right">材料及施工费(元):</td>
		<td><asp:TextBox ID="FuJiaFei" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
		<td align="right">总成本(元):</td>
		<td><asp:Label ID="ChengBen" runat="server" Text="0"></asp:Label></td>
	</tr>
    
	<tr height="36">
		<td align="right">验收意见:</td>
		<td colspan="3"><asp:TextBox ID="YanShouYiJian" runat="server" CssClass="textbox" Width="410"></asp:TextBox></td>
		<td align="right">验收人:</td>
		<td><asp:TextBox ID="YanShouRen" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
		</tr>
	<tr height="36">
		<td align="right">备注:</td>
		<td colspan="5"><asp:TextBox ID="BeiZhu" runat="server" CssClass="textbox" Width="410"></asp:TextBox></td>
	</tr>

</table>

</asp:Panel>

<asp:Panel ID="Panel_Msg" runat="server" CssClass="panel2">
    <asp:Label ID="Message" runat="server" Text="" CssClass="prompt"></asp:Label>
</asp:Panel>

</form>
<script>
    var notice = '<%=this.Notice %>';
    if (notice != '') {
        parent.showmsgbox(notice);
    }
</script>
<script>
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }
    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName != "INPUT" || tag.className != "textbox") return;
        if (tag.id == "BeiZhu") return;
        if(e.keyCode==13)e.keyCode = 9;
    }


    function makecalendar(d, o) {
        obj = o;
        idate = makedate(d);
        cdate = new Date(idate.getFullYear(), idate.getMonth(), 1);
        ds.style.left = (getObjectLeft(o) - 60) + "px";
        ds.style.top = (getObjectTop(o) + 5) + "px";
        ds.style.display = 'block';
        showcalendar();
    }
</script>
</body>
</html>
